#ifndef __GenericServerApp_H
#define __GenericServerApp_H

#include <Poco/Util/ServerApplication.h>
#include <Poco/ThreadPool.h>
#include <Poco/NamedEvent.h>
#include <Poco/AutoPtr.h>
#include <Poco/DynamicFactory.h>

class StopRootApplicationNotification;

class GenericServerApp :
	public Poco::Util::ServerApplication
{
public:
	GenericServerApp(void);
	virtual ~GenericServerApp(void);
protected:
	void initialize(Application& self); // load default configuration files, if present
	void uninitialize();

	void defineOptions(Poco::Util::OptionSet& options);

	void handleOption(const std::string& name, const std::string& value);

	void displayHelp();

	void HandleStopRootApp(const Poco::AutoPtr<StopRootApplicationNotification>& aNotification);
	virtual void RegisterSubsystemClasses() {};
public:
	int main(const std::vector<std::string>& args);

protected:
	Poco::NamedEvent iStopEvent;

	bool _helpRequested;
	bool iStopRunningServer;
	Poco::ThreadPool iServerThreadPool;
	Poco::DynamicFactory<Poco::Util::Subsystem> iSubSystemFactory;
	
};


#endif